import { Controller, Get, Post, Put, Delete, Body, Param, Query } from '@nestjs/common';
import { QuestionService } from './question.service';
import { CreateQuestionDto } from './dto/create-question.dto';
import { UpdateQuestionDto } from './dto/update-question.dto';
import { QuestionQueryDto } from './dto/query-question.dto';
import { PaginationResult } from 'src/common/interfaces/pagination-results.interface';
import { Question } from './entities/question.entity';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('Questions')
@Controller('question')
export class QuestionController {
  constructor(private readonly questionService: QuestionService) { }

  @Post('create')
  @ApiOperation({ summary: 'Create a new question' })
  async create(@Body() createQuestionDto: CreateQuestionDto): Promise<Question> {
    return this.questionService.create(createQuestionDto);
  }

  // @Get()
  // async findAll(@Query() questionQueryDto: QuestionQueryDto): Promise<PaginationResult<Question>> {
  //   return this.questionService.findAll(questionQueryDto);
  // }
  @Post('list')
  @ApiOperation({ summary: 'Get a paginated list of questions' })
  findAll(@Body() paginationQuery: QuestionQueryDto) {
    return this.questionService.findAll(paginationQuery);
  }

  @Get(':id')
  @ApiOperation({ summary: 'Get an question by id' })
  // @Public()
  async findOne(@Param('id') id: string): Promise<Question> {
    return this.questionService.findOne(id);
  }

  @Post('update/:id')
  @ApiOperation({ summary: 'Update an question' })
  async update(@Param('id') id: string, @Body() updateQuestionDto: UpdateQuestionDto): Promise<Question> {
    return this.questionService.update(id, updateQuestionDto);
  }

  @Get('delete/:id')
  @ApiOperation({ summary: 'Delete an question' })
  async remove(@Param('id') id: string): Promise<void> {
    await this.questionService.remove(id);
  }

  @Post('getoptions')
  @ApiOperation({ summary: 'Get results options' })
  async findAllResultsOptions() {
    return this.questionService.findAllResultsOptions();
  }
  // @Delete('/delete/:id')
  // async delete(@Param('id') id: string): Promise<void> {
  //   await this.questionService.delete(id);
  // }
}
